package com.controller.lyxmcontroller.controller.index;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.service.lyxmserviceapi.model.ArticleModel;
import com.service.lyxmserviceapi.model.Author;
import com.service.lyxmserviceapi.model.Module;
import com.service.lyxmserviceapi.service.ArticleDetailService;
import com.service.lyxmserviceapi.service.index.IndexService;

@Controller
public class indexController {
	
	@Autowired
	private IndexService indexServiceImpl;
	@Autowired
	private ArticleDetailService articleDetailServiceImpl;
	
	@RequestMapping( value = "/index",method = RequestMethod.GET)
	public String index(Model model,HttpServletResponse response,HttpServletRequest request){
		//获取首页推广文章
		List<ArticleModel> indexArticleList = indexServiceImpl.getIndexArticle();
		model.addAttribute("indexArticleList",indexArticleList);
		//获取首页模块列表
		List<Module> moduleList = indexServiceImpl.getIndexModule();
		model.addAttribute("moduleList",moduleList);
		
		//最近发布模块
		List<ArticleModel> newArticleModelList = articleDetailServiceImpl.getArticleModelListIndex();
		model.addAttribute("newArticleModelList",newArticleModelList);
		//获取作者信息
		List<Author> authorList = indexServiceImpl.getAuthorList();
		model.addAttribute("authorList", authorList);
		
		
		return "/index/index";
	}
}
